package WeekThree;

import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Scanner;

public class Sort {
    public static void main(String[] args) {
        int []arr=new int[5];
        System.out.println("排序前");
        Sort.charu(arr);
        System.out.println("插叙排列后");
        System.out.println(Arrays.toString(arr));
    }
    public static void charu(int[] arr){
        Scanner scanner = new Scanner(System.in);
        for (int i=0;i< arr.length;i++){
            arr[i] = scanner.nextInt();
            int j = i;
            while (j>0){
                if (arr[j]<arr[j-1]){
                    int tem =arr[j];
                    arr[j]=arr[j-1];
                    arr[j-1]=tem;
                    j--;
                }else {
                    break;
                }
            }
        }
    }
}